#!/usr/bin/perl -w

# date2iso
# File ID: 35e0af3c-5d38-11df-8eb4-90e6ba3022ac
# Konverterer obskure dataformater til ISO-8601.

use strict;

my %mnd_str = (
	'Jan' => '01',
	'Feb' => '02',
	'Mar' => '03',
	'Apr' => '04',
	'May' => '05',
	'Jun' => '06',
	'Jul' => '07',
	'Aug' => '08',
	'Sep' => '09',
	'Oct' => '10',
	'Nov' => '11',
	'Dec' => '12'
);

while (<>) {
	s/
		(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+
		(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
		(\d+)\s+
		(\d\d:\d\d:\d\d)\s+
		([A-Za-c]+\s+)?
		(\d\d\d\d)
	/
		sprintf("%s %04u-%s-%02u %s%s",
			$1,
			$6,
			$mnd_str{$2},
			$3,
			$4,
			defined($5)
				? " $5"
				: "",
		)
	/eix;
	s/
		(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s+
		(\d+)\s+
		(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
		(\d\d\d\d)\s+
		(\d\d:\d\d:\d\d)
	/
		sprintf("%s %04u-%s-%02u %s", $1, $4, $mnd_str{$3}, $2, $5)
	/eix;
	print;
}

# vim: set noet :
